<?php 
function removeTitle($string,$keyReplace = "/"){
	 $string = removeAccent($string);
	 $string  =  trim(preg_replace("/[^A-Za-z0-9]/i"," ",$string)); // khong dau
	 $string  =  str_replace(" ","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace("--","-",$string);
	 $string = str_replace($keyReplace,"-",$string);
	 return strtolower($string);
}
function generate_detail_url($type,$row){
    $url = '';
    switch($type){
        case 'products':
            $url = '/san-pham/'.$row['pro_id'].'/'.removeTitle($row['pro_name']).'.html';
            break;
        case 'news':
            $url = '/tin-tuc/'.$row['new_id'].'/'.removeTitle($row['new_title']).'.html';
            break;
        case 'solution':
            $url = '/giai-phap/'.$row['sol_id'].'/'.removeTitle($row['sol_question']).'.html';
            break;
    }
    return $url;
}
function generate_cat_url($type,$row){
    $url = '';
    switch($type){
        case 'products':
            $url = '/danh-muc-san-pham/'.$row['cat_id'].'/'.removeTitle($row['cat_name']);
            break;
        case 'news':
            $url = '/chuyen-muc-tin-tuc/'.$row['cat_id'].'/'.removeTitle($row['cat_name']);
            break;
    }
    return $url;
}
?>